package com.cloud.bc.controller;

import com.cloud.bc.model.domain.UserInfo;
import com.cloud.bc.model.entity.BcSingleContacts;
import com.cloud.bc.model.entity.BcSingles;
import com.cloud.bc.service.BcSingleContactsService;
import com.cloud.bc.service.BcSinglesService;
import com.cloud.bc.service.BcUsersService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("m/center/contact")
@AllArgsConstructor
public class MCenterContactController extends BaseController {
    private final BcUsersService bcUsersService;
    private final BcSingleContactsService bcSingleContactsService;

    /**
     * 联系方式
     */
    @GetMapping("")
    public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = baseView(request,"联系方式", "m/center/contact/index");
        UserInfo userInfo = bcUsersService.getUserInfo(request);
        BcSingleContacts bcSingleContacts = bcSingleContactsService.selectOne(new BcSingleContacts().setUserId(userInfo.getId()));
        view.addObject("data", bcSingleContacts);
        return view;
    }
}
